package com.wymobilearchitecture

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.example.w_library.utils.ActivityManager
import com.wy.common.base.BaseActivity
import com.wymobilearchitecture.demo.banner.BannerActivity

import com.wymobilearchitecture.demo.log.WLogDemo
import com.wymobilearchitecture.demo.tab.TabBottomActivity


class MainActivity : BaseActivity() ,View.OnClickListener,MainActivityLogic.ActivityProvider{

    //MainActivityLogic.ActivityProvider Activity实现了内部的同名方法所以不需要复写
    var logic : MainActivityLogic? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        logic = MainActivityLogic(this,savedInstanceState)

        ActivityManager.instances.addFountBackCallback(object :ActivityManager.FrontBackCallback {
            override fun onChanged(fount: Boolean) {


            }
        })

    }

    override fun onClick(v: View?) {

        when(v!!.id){
            R.id.btn_log -> {
                startActivity(Intent(this@MainActivity,
                    WLogDemo::class.java))
            }

            R.id.btn_tab -> {
                startActivity(Intent(this@MainActivity,TabBottomActivity::class.java))
            }

            R.id.btn_banner ->{
                startActivity(Intent(this@MainActivity,BannerActivity::class.java))
            }
        }
    }

    /**
     * 处理当应用被回收之后 Activity 重新加载问题
     */
    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
    }
}
